package com.marchsoft.campushelp.security.vo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.sql.Timestamp;
import java.util.Collection;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 源
 * Date: 2020-03-14
 * Time: 10:10
 */
@Getter
@AllArgsConstructor
public class MyJwtUser implements UserDetails {
    private Long id;
    private String nickName;
    private String avatar;
    private Integer vipType;
    @JsonIgnore
    private String loginPassword;
    @JsonIgnore
    private String payPassword;
    private String name;
    private int age;
    private String phone;
    private String campus;
    private int user_type;
    //启用或禁用1,2
    private int disable;
    //删除1未删2删除
    private int delete_type;
    private Timestamp creatTime;
    private String permission;

    @JsonIgnore
    private final List<GrantedAuthority> authorities;





    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return loginPassword;
    }

    @Override
    public String getUsername() {
        return phone;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
